package converter;

import bean.User;
//import ognl.DefaultTypeConverter;
import org.apache.struts2.util.StrutsTypeConverter;

import java.util.Map;

public class UserConverter extends StrutsTypeConverter{

    @Override
    public Object convertFromString(Map map, String[] strings, Class aClass) {
        if(aClass == User.class){
            User user = new User();
            user.setName(strings[0]);
            user.setPass(strings[1]);
            return user;
        }
        return null;
    }

    @Override
    public String convertToString(Map map, Object o) {
        User user = (User) o;
        return "<"+user.getName()+","+user.getPass()+">";
    }
}
